Skip to content

test(app): smoke tests for named routes, healthz, and set_error_handler (#342) - #388

Merged
gg582 merged 1 commit into
c4punks:devfrom
Bhumika-1432006:test/342-app-routing-error-handler
Oct 17, 2026
Merged

gg582 merged 1 commit into
c4punks:devfrom
Bhumika-1432006:test/342-app-routing-error-handler

Conversation

@Bhumika-1432006

Copy link
Copy Markdown
Contributor

Four cwist_app_* functions from issue #342's uncovered list have no test: cwist_app_post_named, cwist_app_delete_named, cwist_app_enable_healthz, and cwist_app_set_error_handler.

What this adds: tests/test_app_named_routes_and_error_handler.c with one case per function:

  • post_named: register a POST route with a name, verify cwist_url_for returns the registered path.
  • delete_named: same for DELETE; confirms paths with :param segments are stored.
  • enable_healthz: call it and confirm no crash; check cwist_url_for for the /healthz path when a name is registered.
  • set_error_handler: verify app->error_handler is NULL before the call, set to the supplied function pointer after, and NULL-cleared on a second call with NULL. Confirm NULL app is a safe no-op.

How it was verified: no live server is started; the tests only exercise the registration and lookup paths. The assertions follow directly from the function signatures and the app struct layout in app.h. The test is wired into make test via a new Makefile target.

What it does not do: does not cover cwist_app_multiport, cwist_app_set_tls_groups, cwist_app_ws_opt, or the other uncovered functions listed in issue #342.

…er (c4punks#342)

Four cwist_app_* functions from issue c4punks#342's uncovered list have no test:
cwist_app_post_named, cwist_app_delete_named, cwist_app_enable_healthz, and
cwist_app_set_error_handler.

This adds tests/test_app_named_routes_and_error_handler.c with one case per
function:

- post_named: register a POST route with a name and verify cwist_url_for
  returns the registered path.
- delete_named: same for DELETE; confirms :param paths are stored.
- enable_healthz: call it and confirm no crash; check cwist_url_for for the
  /healthz path when a name is registered.
- set_error_handler: verify app->error_handler is NULL before the call, set
  to the supplied function pointer after, and NULL-cleared on a second call
  with NULL. Confirm NULL app is a safe no-op.

No live server is started; the tests only exercise registration and lookup.
The test is wired into make test via a new Makefile target.
@gg582
gg582 merged commit eebc6fd into c4punks:dev Oct 17, 2026
25 of 26 checks passed
gg582 added a commit that referenced this pull request Oct 17, 2026
cwist_app_{delete_named,enable_healthz,post_named,set_error_handler},
cwist_bind_write_error_response, and cwist_url_for gained wired unit
tests in #387/#388; remove them from api-untested-baseline.txt.
gg582 pushed a commit that referenced this pull request Oct 17, 2026
…er (#342) (#388)

Four cwist_app_* functions from issue #342's uncovered list have no test:
cwist_app_post_named, cwist_app_delete_named, cwist_app_enable_healthz, and
cwist_app_set_error_handler.

This adds tests/test_app_named_routes_and_error_handler.c with one case per
function:

- post_named: register a POST route with a name and verify cwist_url_for
  returns the registered path.
- delete_named: same for DELETE; confirms :param paths are stored.
- enable_healthz: call it and confirm no crash; check cwist_url_for for the
  /healthz path when a name is registered.
- set_error_handler: verify app->error_handler is NULL before the call, set
  to the supplied function pointer after, and NULL-cleared on a second call
  with NULL. Confirm NULL app is a safe no-op.

No live server is started; the tests only exercise registration and lookup.
The test is wired into make test via a new Makefile target.
gg582 added a commit that referenced this pull request Oct 17, 2026
cwist_app_{delete_named,enable_healthz,post_named,set_error_handler},
cwist_bind_write_error_response, and cwist_url_for gained wired unit
tests in #387/#388; remove them from api-untested-baseline.txt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants